package com.yc.http.d0706;


import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

public class HttpSession {

    /**
     * getId();
     * <p>
     * getAttribue(name)
     * setAttribue(name, value)
     * long getLastAccessedTime();
     * <p>
     * getMaxInactiveInterval();
     * <p>
     * getCreationTime();
     */

    public HttpSession() {
        id = UUID.randomUUID().toString().replaceAll("-", "");
    }

    /**
     * 会话ID
     */
    String id;

    public String getId() {
        return id;
    }

    long longastAccessedTime;

    public long getLastAccessedTime() {
        return longastAccessedTime;
    }

    /**
     * 这是非官方的方法, 为简化编程
     *
     * @param time
     * @return
     */
    public void setLastAccessedTime(long time) {
        longastAccessedTime = time;
    }

    // 属性集合
    private Map<String, Object> attributeMap = new HashMap<>();

    public Object getAttribute(String name) {
        return attributeMap.get(name);
    }

    public void setAttribute(String name, Object value) {
        attributeMap.put(name, value);
    }

}
